# Contributor: goodspb <goodspb.luo@gmail.com>
# Contributor: Adriaan Groenenboom <agboom@pm.me>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php82-pdlib
_extname=pdlib
pkgver=1.1.0
pkgrel=1
pkgdesc="PHP 8.2 extension for Dlib"
url="https://github.com/goodspb/pdlib"
# x86, s390x: check fails
# ppc64le: fails to build https://github.com/goodspb/pdlib/issues/19
arch="all !x86 !s390x !ppc64le"
license="MIT"
_phpv=82
_php=php$_phpv
depends="$_php-common dlib"
makedepends="dlib-dev $_php-dev $_php-bz2"
source="php-$_extname-$pkgver.tar.gz::https://github.com/goodspb/$_extname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_extname-$pkgver"

build() {
	phpize$_phpv
	./configure --prefix=/usr --with-php-config=php-config$_phpv
	make
}

check() {
	# Tests require bz2 extension which is not bundled
	local _modules=/usr/lib/$_php/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		TESTS=--show-diff SKIP_ONLINE_TESTS=1 \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=$_modules/bz2.so \
		-d extension=modules/$_extname.so"
	$_php -dextension=modules/$_extname.so --ri $_extname
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/$_php/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/$_extname.ini
}

sha512sums="
a87316495c04e5ca9b8b6980f859b1e9b4cfccc9b9ad0ab5f83320f2e9bc2f92a006fe0fe9621b21a9755efdf719e533519dfc2319d437a5475e067d5e633661  php-pdlib-1.1.0.tar.gz
"
